Determining Who Is Logged On
How
do you know who’s logged on to a Windows 7 machine? For example, what
if you’re sitting down at another person’s computer and you’re not sure
who’s logged on and what privileges they have?
No problem. The WHOAMI command gives you information about the user who is currently logged on to the computer:
WHOAMI [/UPN | /FQDN | LOGONID] [/USER | /GROUPS | /PRIV] [/ALL] [/FO format]
This command redirects the current user’s SID, username, groups, and privileges to a file named whoami.txt using the list format, and then opens the file.
For example, start a Command Prompt session on the computer (in Windows 7, select Start, type command into the Search box, and press Enter), and run the following command:
whoami /all /fo list > whoami.txt&&start whoami.txt
Tip
My command is actually two
commands in one, thanks to the DOSKEY && operator, which lets
you run multiple commands on a single line.
/UPN | (Domains only) Returns the current user’s name using the user principal name (UPN) format. |
/FQDN | (Domains only) Returns the current user’s name using the fully qualified domain name (FQDN) format. |
/LOGONID | Returns the current user’s security identifier (SID). |
/USER | Returns the current username using the computer\user format. |
/GROUPS | Returns the groups of which the current user is a member. |
/PRIV | Returns the current user’s privileges. |
/ALL | Returns the current user’s SID, username, groups, and privileges. |
/FO
format | The output format, where format is one of the following values: |
| table | The output is displayed in a row-and-column format, with headers in the first row and values in subsequent rows. |
| list | The output is displayed in a two-column list, with the headers in the first column and values in the second column. |
| csv | The output is displayed with headers and values separated by commas. The headers appear on the first line. |